package svc

import (
	"github.com/zeromicro/go-zero/zrpc"
	"zf_base/api/internal/config"
	"zf_base/api/pkg/interceptors"

	"zf_base/rpc/user"
)

type ServiceContext struct {
	Config  config.Config
	UserRPC user.User
}

func NewServiceContext(c config.Config) *ServiceContext {
	// 自定义拦截器
	userRPC := zrpc.MustNewClient(c.UserRPC, zrpc.WithUnaryClientInterceptor(interceptors.ClientErrorInterceptor()))

	return &ServiceContext{
		Config:  c,
		UserRPC: user.NewUser(userRPC),
	}
}
